package com.itheima.day03.mypolymorpic.test2;

public class Test {
    public static void main(String[] args) {
        /*eatDog(new Dog());
        eatCat(new Cat());*/
        eatAnimal(new Animal());
        eatAnimal(new Dog());
        eatAnimal(new Cat());

    }
    /*public static void eatDog(Dog d){
        d.eat();
    }
    public static void eatCat(Cat c){
        c.eat();
    }*/
    public static void eatAnimal(Animal a){
        a.eat();
        if(a instanceof Dog){
            Dog d = (Dog) a;
            d.method();
        }
        if(a instanceof Cat){
            Cat c = (Cat) a;
            c.method();
        }
    }
}

class Animal{
    public void eat(){
        System.out.println("动物进食");
    }
}
class Dog extends Animal{
    @Override
    public void eat(){
        System.out.println("狗吃🥁");
    }
    public void method(){
        System.out.println("狗黑皮");
    }
}
class Cat extends Animal{
    @Override
    public void eat(){
        System.out.println("猫吃🐟");
    }
    public void method(){
        System.out.println("躲猫猫");
    }
}
